<?php
/**
 * Created by PhpStorm.
 * User: Michael Ma
 * Date: 2017/4/16
 * Time: 20:11
 */

header("Content-Type: text/plain;charset=utf-8");
header("Access-Control-Allow-Origin:*");
header("Access-Control-Methods:POST,GET");

//连接数据库
require_once ("classes/conn.php");
require_once ("classes/user.php");

//接受前台传过来的数据
$name = isset($_POST['name']) ? $_POST['name'] : '';                     //用户名
$psw = isset($_POST['psw']) ? $_POST['psw'] : '';                        //用户密码
//$name = "xuemei";
//$psw = 12345;

//实例化
$login = new User();
$result = $login -> login($name);
$result1 = mysqli_fetch_assoc($result);
//echo $result1['nenufish_user_psw'];
//echo $result1['nenufish_user_id'];

//账号密码判断
if ($result1['nenufish_user_psw'] == $psw){
    $id = $result1['nenufish_user_id'];
}else{
    $id = "";
}
echo json_encode($id,JSON_UNESCAPED_UNICODE);

?>

